package com.wnhz.work.jy.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.wnhz.work.jy.MyMain;
import com.wnhz.work.jy.R;
import com.wnhz.work.jy.activity.TrendChartActivity;
import com.wnhz.work.jy.adapter.Home2Fragment1Adapter;
import com.wnhz.work.jy.bean.ManageMoneyBean;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 * 理财
 */
public class HomeFragment2 extends Fragment{
    private View max_view;
    private TextView title;
    private MyMain mainActivity;

    private ListView collect_listview;//收藏

    private List<ManageMoneyBean> collect_list = new ArrayList<>();

    private Home2Fragment1Adapter collect_adapter;
    private Home2Fragment1Adapter invest_adapter;

    private View blank_lay;
    private ImageView blank_img;
    private TextView blank_tv;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        mainActivity = (MyMain) getActivity();
        max_view = inflater.inflate(R.layout.homefragment2, container, false);
        return max_view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initTirle();
        setBlank();
        collect_listview = (ListView) max_view.findViewById(R.id.collect_listview);


        collect_list.clear();
        for (int i = 0; i < 4; i++) {
            ManageMoneyBean bean = new ManageMoneyBean();
            collect_list.add(bean);
        }

        collect_adapter = new Home2Fragment1Adapter(getActivity(), collect_list);

        collect_listview.setAdapter(collect_adapter);
        collect_listview.setOnItemClickListener(collect_itemClick);
    }

    AdapterView.OnItemClickListener collect_itemClick = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            startActivity(new Intent(mainActivity, TrendChartActivity.class));
        }
    };

    private void setBlank() {
        blank_lay = max_view.findViewById(R.id.include_shopping_null);
        blank_img = (ImageView) blank_lay.findViewById(R.id.blank_img);
        blank_tv = (TextView) blank_lay.findViewById(R.id.blank_tv);
        blank_tv.setText("模块开发中");
        blank_img.setImageResource(R.mipmap.ic_kaifazhong);
    }




    private void initTirle() {
        title = (TextView) max_view.findViewById(R.id.view_main_middle_title);
        title.setText("理财");
        max_view.findViewById(R.id.btn_main_left).setVisibility(View.GONE);
    }



}
